﻿using Azure.Core;
using Microsoft.AspNetCore.Mvc;
using SALIRAPI.Common;
using SALIRAPI.Entities.Map;
using SqlSugar;

namespace SALIRAPI.Controllers
{
    public class TsPlanController : BaseApiController
    {
        private readonly SqlSugarClient isc;
        public TsPlanController(SqlSugarClient isc)
        {
            this.isc = isc;
        }

        [HttpGet]
        public async Task<IActionResult> QueryPlan(string user_id)
        {
            var result = isc.Queryable<TsPlan>().Where(x => x.USER_ID == user_id).ToList();
            return ApiResult(true, "查询完成", result);
        }

        [HttpPost]
        public async Task<int> AddPlan(TsPlan tsPlan)
        {
            
            tsPlan.Id = SysHelper.GetGuid();
            tsPlan.CREATE_DATE = DateTime.Now;
            return isc.Insertable<TsPlan>(tsPlan).ExecuteCommand();
        }
    }
}
